import java.util.Stack;

public class Main {

    //最小栈
//    class MinStack1 {
//        public Stack<Integer> stack;
//        public  Stack<Integer> minStack;
//        public MinStack1() {
//            stack = new Stack<>();
//            minStack = new Stack<>();
//        }
//
//        public void push(int val) {
//            stack.push(val);
//            if(minStack.empty()) {
//                minStack.push(val);
//            }else {
//                int peekVal = minStack.peek();
//                if(val <= peekVal) {
//                    minStack.push(val);
//                }
//            }
//        }
//        public void pop() {
//            if(stack.empty()) {
//                return;
//            }
//            int popVal = stack.pop();
//            if(popVal == minStack.peek()) {
//                minStack.pop();
//            }
//        }
//
//        public int top() {
//            if(stack.empty()) {
//                return -1;
//            }
//            return stack.peek();
//        }
//
//        public int getMin() {
//            if(minStack.empty()) {
//                return -1;
//            }
//            return minStack.peek();
//        }
//
//    }

    //逆波兰表达式
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack=new Stack<>();
        for (int i=0;i<tokens.length;i++) {
            if(calculation(tokens[i])){
                int val1=stack.pop();
                int val2=stack.pop();
                switch(tokens[i]){
                    case "+":
                        stack.push(val2+val1);
                        break;
                    case "-":
                        stack.push(val2-val1);
                        break;
                    case "*":
                        stack.push(val2*val1);
                        break;
                    case "/":
                        stack.push(val2/val1);
                        break;
                }
            }else{
                stack.push(Integer.valueOf(tokens[i]));
            }
        }
        return stack.pop();
    }
    private boolean calculation(String s){
        if(s.equals("+")||s.equals("-")||s.equals("*")||s.equals("/")){
            return true;
        }
        return false;
    }

    //最小栈
    class MinStack {
        public Stack<Integer> stack;
        public  Stack<Integer> minStack;
        public MinStack() {
            stack = new Stack<>();
            minStack = new Stack<>();
            minStack.push(Integer.MAX_VALUE);//初始化存储了一个最大的值
        }

        public void push(int val) {
           stack.push(val);
           minStack.push(Math.min(val,minStack.pop()));
        }
        public void pop() {
            stack.pop();
            minStack.pop();
        }

        public int top() {
            return stack.peek();
        }

        public int getMin() {
            return minStack.peek();
        }

    }

    //判断是否回文
    public boolean isPalindrome(String s) {
        char[] chars=(s.toLowerCase()).toCharArray();
        int start = 0, end = chars.length-1;
        while (start < end) {
            while(!isEnglishWord(chars[start])&&start<end){
                start++;
            }
            while(!isEnglishWord(chars[end])&&start<end){
                end--;
            }
            if(start < end && chars[start] != chars[end]){
                    return false;
                }
                start++;
                end--;
        }
        return true;
    }

    public boolean isEnglishWord(char x) {
        if(x<='z'&&x>='a'||Character.isDigit(x)){
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        String str = "0P";
        System.out.println(new Main().isPalindrome(str));

    }



}